package qing.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;
import javax.persistence.Version;
import javax.validation.constraints.Past;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotEmpty;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Required;
import org.springframework.format.annotation.DateTimeFormat;


@Entity
@Table
public class Person extends AbstractEntity<String> {


	@Id
	@GeneratedValue(generator = "paymentableGenerator")
	@GenericGenerator(name = "paymentableGenerator", strategy = "uuid")
	private String id;	
	
	//貌似解决并发控制数据问题
	@Version
	private Integer version;
	
	private boolean deleted;
	
	//时间戳
	@Temporal(value=TemporalType.TIMESTAMP)
	private Date dateCreated=new Date();
	
	@Column(updatable=false)
	@Length(min=3,max=20,message="账号名称必须为3-20位字母和数字")
	private String username;
	

	private String password;
	
	private Float account;
	
	private Float amount;
	
	private Float blockAmount;
	
	
	private String name;
	
	@Email(message="邮箱格式错误")
	private String email;
	
	///保存临时验证码
	private String code;

	@Past
	@DateTimeFormat(pattern="yyyy-MM-dd")
	private Date birthday;
	
	private String sex="1";
	
	private String ipCreated;
	
	@Temporal(TemporalType.TIMESTAMP)
	private Date dateLastActived=new Date();
	
	private String ipLastActived;
	
	/*@ManyToMany(mappedBy="administrators")
	private Set<Board> boardsAdministrated=new HashSet<Board>();*/



	/*public Set<Board> getBoardsAdministrated() {
		return boardsAdministrated;
	}

	public void setBoardsAdministrated(Set<Board> boardsAdministrated) {
		this.boardsAdministrated = boardsAdministrated;
	}*/

	


	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Float getAccount() {
		return account;
	}

	public void setAccount(Float account) {
		this.account = account;
	}

	public Float getAmount() {
		return amount;
	}

	public void setAmount(Float amount) {
		this.amount = amount;
	}

	public Float getBlockAmount() {
		return blockAmount;
	}

	public void setBlockAmount(Float blockAmount) {
		this.blockAmount = blockAmount;
	}


	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(boolean deleted) {
		this.deleted = deleted;
	}

	public Date getDateCreated() {
		return dateCreated;
	}

	public void setDateCreated(Date dateCreated) {
		this.dateCreated = dateCreated;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getIpCreated() {
		return ipCreated;
	}

	public void setIpCreated(String ipCreated) {
		this.ipCreated = ipCreated;
	}

	public Date getDateLastActived() {
		return dateLastActived;
	}

	public void setDateLastActived(Date dateLastActived) {
		this.dateLastActived = dateLastActived;
	}

	public String getIpLastActived() {
		return ipLastActived;
	}

	public void setIpLastActived(String ipLastActived) {
		this.ipLastActived = ipLastActived;
	}



	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Override
	public String toString() {
		return "Person [id=" + id + ", dateCreated=" + dateCreated + ", username=" + username + ", password=" + password
				+ ", account=" + account + "]";
	}

	public Person() {	}

	public Person(String username, String password, Float account) {
		this.username = username;
		this.password = password;
		this.account = account;
	}
	

	
	
	
}
